program kliper;

{%ToDo 'kliper.todo'}

uses
  Forms,
  SysUtils,
  Dialogs,
  main in 'main.pas' {klipermainform},
  engine in 'engine.pas',
  Core in 'Core.pas',
  engineform in 'engineform.pas' {TLForm},
  settings in 'settings.pas' {settingsform},
  about in 'about.pas' {aboutform},
  helppas in 'helppas.pas' {Help},
  update in 'update.pas' {up2date},
  windows,
  messages,
  subfinder in 'subfinder.pas' {subform},
  napisy in 'napisy.pas',
  upaski in 'upaski.pas',
  statusForm in 'statusForm.pas' {statusFormFrm},
  fileselect in 'fileselect.pas' {FrmSelectFile},
  closeForm in 'closeForm.pas' {closeFormFrm},
  Uwlasci in 'Uwlasci.pas' {frwlasciwosci},
  utils in 'utils.pas',
  defaults in 'defaults.pas',
  KliperLabel in 'KliperLabel.pas',
  ukapsule in 'ukapsule.pas' {kapsule},
  upomocnicza in 'upomocnicza.pas' {pomocnicza},
  loader in 'loader.pas',
  scheduler in 'scheduler.pas',
  session in 'session.pas',
  recent in 'recent.pas',
  player in 'player.pas',
  display in 'display.pas',
  media in 'media.pas';


{$R *.res}
{$R icons.res}

var
  hwnd: integer;
  hMutex: integer;
  wParam: integer;
 // mainform: tklipermainform;
  s: string;

begin
  DeleteFile(pchar(extractfiledir(paramstr(0)) + '\mplayer\config'));
  Application.Initialize;
  Application.Title := 'Kliper';
  hMutex := CreateMutex(nil, True, 'kliper');
  if GetLastError = ERROR_ALREADY_EXISTS then
  begin

   //for i:=1 to paramcount do begin
    s := paramstr(1);
    //end;
    hwnd := findwindow('Tklipermainform', nil);
    if (hwnd = 0) then
      messagebox(0, 'Class Notification Error', '', MB_ICONERROR);
    wParam := GlobalAddAtom(pchar(s));
    PostMessage(HWnd, WM_USER, wParam, 0);
    halt;
  end;


  Application.CreateForm(Tklipermainform, mainform);
  Application.CreateForm(Tpomocnicza, pomocnicza);
  Application.Run;

  if hMutex <> 0 then begin
    CloseHandle(hMutex);

  end;
end.

